// 注册页面服务逻辑

import type { RegisterForm, RegisterResponse } from './types'

const API_BASE_URL = 'http://localhost:3000/api'

// 注册
export const register = async (form: RegisterForm): Promise<RegisterResponse> => {
  const res = await fetch(`${API_BASE_URL}/register`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(form)
  })

  if (!res.ok) {
    const error = await res.json()
    throw new Error(error.message || '注册失败')
  }

  return await res.json()
} 